package com.share.shareplatform.pojo;

import com.share.shareplatform.pojo.exception.LogicException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Repertory {

    private Long id;
    private Integer number;

    public static List<Repertory> resolve(String idNumber){
        try {
            String[] rs = idNumber.split(",");
            List<Repertory> list=new ArrayList<>();
            for(String s:rs){
                String[] repertoryStr = s.split("-");
                Repertory repertory = new Repertory();
                repertory.setId(Long.parseLong(repertoryStr[0]));
                repertory.setNumber(Integer.parseInt(repertoryStr[1]));
                list.add(repertory);
            }
            return list;
        }catch (Exception e){
            throw new LogicException("格式错误");
        }
    }

}
